home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Java Developer's Companion
/
Java Developer's Companion.iso
/
Javacup
/
IN231VFD.TAR
/
internet
/
IN231VFD
/
Clock.java
< prev
next >
Wrap
Text File
|
1996-05-21
|
777b
|
42 lines
// Clock.java - Simple AWT clock object
//
// Copyright (C) 1996 by Dale Gass
// Non-exclusive license granted to MKS, Inc.
//
import java.lang.*;
import java.util.*;
import java.awt.*;
import java.net.*;
import java.applet.*;
class Clock extends Label implements Runnable {
Thread me;
// Updates the time
void update() {
Date now = new Date();
setText(now.toString());
}
// Constructor
public Clock() {
setFont(new Font("Times Roman", Font.BOLD, 20));
Date now = new Date();
(me = new Thread(this)).start();
update();
invalidate();
}
// Dynamically update the time
public void run() {
while (true) {
try { me.sleep(1000); } catch (Exception e) { }
update();
}
}
}